<!DOCTYPE html>
<html>
<head>
    <title>Home</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            background-color: #f4f4f4;
            padding: 50px;
        }
        .container {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
            display: inline-block;
        }
        h1 {
            color: #333;
        }
        a {
            display: inline-block;
            padding: 10px 20px;
            margin: 10px;
            text-decoration: none;
            color: white;
            background-color: #007BFF;
            border-radius: 5px;
            transition: background 0.3s;
        }
        a:hover {
            background-color: #0056b3;
        }
        #file-list {
            margin-top: 20px;
            text-align: left;
            display: inline-block;
        }
        .file-item {
            padding: 5px;
            margin: 5px;
            background: #e9ecef;
            border-radius: 5px;
        }
    </style>
    <script>
        function fetchFiles() {
            fetch('/ocred_files')
                .then(response => response.json())
                .then(data => {
                    let fileList = document.getElementById("file-list");
                    fileList.innerHTML = "";
                    data.files.forEach(file => {
                        let fileItem = document.createElement("div");
                        fileItem.className = "file-item";
                        fileItem.innerHTML = `<a href="/download/${file}" download>${file}</a>`;
                        fileList.appendChild(fileItem);
                    });
                })
                .catch(error => console.error("Error fetching files:", error));
        }
        setInterval(fetchFiles, 5000);
    </script>
</head>
<body>
    <h1>欢迎来到 Flask 认证系统</h1>
{#    <a href="{{ url_for('login') }}">登录</a> | <a href="{{ url_for('register') }}">注册</a>#}
    <h3 >OCR识别文件</h3>
    <form action="{{ url_for('upload') }}" method="post" enctype="multipart/form-data">
        <input type="file" name="file">
        <button type="submit">上传文件</button>
    </form>
<div id="file-list"></div>
</body>
</html>
